	 
	//定义WebCCX类
	function  WebCCX()
	{
		this.ws = null;   //websocket实例变量;
		this.js = null;   //jsAgentStatus座席状态实例变量
	}
	 
		
	 //连接WebCCX的服务器端
	var wss;
	WebCCX.prototype.ccxOpen = function(CTIIp,CTIPort)
	{    
		myCTIIp = CTIIp;
		myCTIPort = CTIPort;
		this.ws = new WebSocket('ws://'+myCTIIp+':'+myCTIPort+'/ccxGwDemo/websocket/');
		wss = this.ws; 
		this.ws.onerror = function(event) 
		{
			onError(event)
		};
		
		this.ws.onopen = function(event)
		{
			onOpen(event)
		};

		this.ws.onmessage = function(event) 
		{
			onMessage(event)
		};
		
		this.ws.onclose = function(event)
		{
			onClose(event)
		};
	}

	function onOpen(event)
	{
		
	}
	function onError(event) 
	{
	   alert("无法连接服务器"+","+event.data);
	 }
	 
	function onClose(event) 
	{
		Agent_m_eState[Agent_E_AGENT_STATE_TYPE_BASE]	=	Agent_E_AGENT_STATE_INIT; 
		Agent_m_eState[Agent_E_AGENT_STATE_TYPE_VOICE]	=	Agent_E_AGENT_STATE_INIT;
		Agent_m_eState[Agent_E_AGENT_STATE_TYPE_MEDIA]	=	Agent_E_AGENT_STATE_INIT;
		alert("WebSocketCcxServer服务器连接关闭"+":"+event.reason);
	} 


	//回调函数处理
	evt_Login = function(nResult, lpszDesc)
	{
		 console.log("OnLoginResp Result:"+nResult+" Desc:"+lpszDesc);
	}

	evt_CallStateChanged = function(CallID, State,StateName)
	{
		console.log("OnCallStateChanged CallID:"+CallID+" State:"+State+" StateName:"+StateName);
	}

	evt_AgentStateChanged = function(nStateType,nStateCode,lpszStateName, nSubCode,lpszSubName)
	{
		console.log("AgentStateChanged StateType:"+nStateType+" StateCode:"+nStateCode+" StateName:"+lpszStateName+" SubCode:"+nSubCode+" SubName:"+lpszSubName);
	}

	evt_CallComing = function(lpszCallID,nCallType , nCallDirect , lpszOrgANI , lpszOrgDNIS , lpszAlertDev , lpszCallData ,lpszImrQueueID)
	{
		console.log("CallComing CallID:"+lpszCallID+" CallTyp:"+nCallType+" CallDirect:"+nCallDirect+" OrgANI:"+lpszOrgANI+" OrgDNIS:"+lpszOrgDNIS+" AlertDev:"+lpszAlertDev+" CallDat:"+lpszCallData+" ImrQueueID:"+lpszImrQueueID);
	}

	evt_CallConnect = function(lpszCallID , nCallType , nCallDirect , lpszOrgANI, lpszOrgDNIS, lpszAnsweringDev , lpszCallData)
	{
		console.log("CallConnect CallID:"+lpszCallID+" CallTyp:"+nCallType+" CallDirect:"+nCallDirect+" OrgANI:"+lpszOrgANI+" OrgDNIS:"+lpszOrgDNIS+" AlertDev:"+lpszAlertDev+" CallDat:"+lpszCallData);
	}

	evt_CallOver = function(lpszCallID,nReason, nCode , lpszReasonDesc)
	{
		console.log("CallOver CallI:"+lpszCallID+" Reaso:"+nReason+" Cod:"+nCode+" ReasonDesc:"+lpszReasonDesc);
	}

	evt_CallTransferred = function(lpszCallID,nMsgType,nCallType,nCallDirect,lpszOrgANI,lpszOrgDNIS,lpszTransferredOut,lpszTransferredIn,nDataLen,lpszCallData)
	{
		console.log("CallTransferred CallID:"+lpszCallID+" MsgType:"+nMsgType+" CallType:"+nCallType+" CallDirect:"+nCallDirect+" OrgANI:"+lpszOrgANI+" OrgDNIS:"+lpszOrgDNIS+" TransferredOut:"+lpszTransferredOut+" TransferredIn:"+lpszTransferredIn+" DataLen:"+nDataLen+" CallData:"+lpszCallData);
	}

	evt_CalloutInit = function(lpszCallID,  nCallType,  nCallDirect,  lpszOrgANI,  lpszOrgDNIS,  lpszDNIS,  lpszCallData)
	{
		console.log("CalloutInit CallID:"+lpszCallID+" CallType:"+nCallType+" CallDirect:"+nCallDirect+" OrgANI:"+lpszOrgANI+" OrgDNIS:"+lpszOrgDNIS+" DNIS:"+lpszDNIS+" CallData:"+lpszCallData);
	}

	evt_CallAlerting = function(CallID, AlertingDevice){
		console.log("CallAlerting CallID:"+CallID+" AlertingDevice:"+AlertingDevice);
	}

	evt_CalloutAnswered = function(CallID, AnsweredDevice)
	{
		console.log("CalloutAnswered CallID:"+CallID+" AnsweredDevice:"+AnsweredDevice);
	}

	evt_Disconnected = function(nResult, lpszResultDesc)
	{
		console.log("Disconnected nResult:"+nResult+" lpszResultDesc:"+lpszResultDesc);
	}

	evt_OnLogoutResp = function(nResult, lpszDesc)
	{
		console.log("OnLoginResp Result:"+nResult+" Desc:"+lpszDesc);
	}
	
	evt_AFWKTimeout = function(nResult, lpszDesc)
	{
		console.log("OnLoginResp Result:"+nResult+" Desc:"+lpszDesc);
	}
	
	evt_Message = function(Message)
	{
		console.log("Message:"+Message);
	}
	evt_OnAgentList = function(Result,Desc,AgentList)
	{
		console.log("OnAgentList Result:"+Result+" Desc:"+Desc+" AgentList:"+AgentList);
	}
	//接口回调函数初始参数
	var EventOrResp = 
	{
		'OnMessage':evt_Message,
		'OnLoginResp':evt_Login,
		'OnCallStateChanged':evt_CallStateChanged,
		'OnSetAgentStateResp':evt_AgentStateChanged,
		'OnAgentStateChanged':evt_AgentStateChanged,
		'OnAgentStateChangedEx':evt_AgentStateChanged,
		'OnLogoutResp': evt_OnLogoutResp,
		'OnCallComing': evt_CallComing,
		'OnCallConnected': evt_CallConnect,
		'OnCallOver': evt_CallOver,
		'OnCallTransferred': evt_CallTransferred,
		'OnOBCallDialing': evt_CalloutInit,
		'OnOBCallAnswered':evt_CalloutAnswered,
		'OnOBCallAlerting': evt_CallAlerting,
		'OnDisconnected': evt_Disconnected,
		'OnAgentList':evt_OnAgentList,
		'OnAFWKTimeout':evt_AFWKTimeout
	};

	WebCCX.setEventOrResp = function( name, handler ) 
	{
		 EventOrResp[ name ] = handler;
	};


	WebCCX.getEventOrResp = function( name ) 
	{
		 return EventOrResp[ name ];
	};

	// 设置回调函数.
	WebCCX.prototype.ccxSetHandles = function( handlers ) 
	{
		  if ( typeof handlers !== 'object' ) 
			{
			   console.log("bad args in setHandlers");
			   return 'error_bad_args';
		   }
		  var ret = 'ok';
		  var name;
		  for ( name in handlers ) 
		   {
			if ( handlers.hasOwnProperty( name ) ) 
			  {
			  if ( name && handlers [ name ] && typeof handlers [name] === 'function' ) 
				{
				if (
				    name === 'OnMessage'||
				    name === 'OnLoginResp' ||
					name === 'OnCallStateChanged' ||
					name === 'OnSetAgentStateResp' ||
					name === 'OnAgentStateChanged' ||
					name === 'OnAgentStateChangedEx' ||
					name === 'OnLogoutResp' ||
					name === 'OnCallComing' ||
					name === 'OnCallConnected' ||
					name === 'OnCallOver' ||
					name === 'OnCallTransferred' ||
					name === 'OnOBCallDialing' ||
					name === 'OnOBCallAnswered' ||
					name === 'OnOBCallAlerting' ||
					name === 'OnDisconnected' ||
					name === 'OnAgentList'||
					name === 'OnAFWKTimeout'
				   ) 
				{
					WebCCX.setEventOrResp( name, handlers [name] );
				} 
				else 
				{
				  ret = 'error_bad_args';
				  break;
				}
			  }
			}
		  }
		return ret;
	};

	//断开与WebCCX服务器端的连接(先判断是否签出，没有签出则先签出在断开websoket--未做)
	WebCCX.prototype.ccxClose = function()
	{
		 OnDisconnected("","");
	}

	//座席签入
	WebCCX.prototype.AgentLogin = function(AgentID,AgentPass,DeviceID,IPAddress)
	{   
		myDeviceID = DeviceID;
		myAgentID = AgentID;
		myAgentPass = AgentPass;
		//getNoticeCount();
		this.js = new jsAgentStatus();//实例化坐席状态
		//openccx.initCallCount();//获取全部类型媒体呼叫，未处理完成的数量
		if (myDeviceID == null||myDeviceID==""){	// 判断设备号是否有效
			alert("设备无效");
			return ;
		}

		this.ws.send(JSON.stringify({  //发送签入数据
			             Command:"Login",
			             AgentID:AgentID,
						 AgentPassword:AgentPass,
						 DeviceID:myDeviceID,
						 IPAddress:IPAddress,
						 KEY:"",
						 ExtData:"ExtData"
			         }));
	}

	//座席签出
	WebCCX.prototype.AgentLogout = function(opAgentID,code)
	{
	   this.ws.send(JSON.stringify({ //发送签出入数据
			             Command:"Logout",
			             OpAgentID:opAgentID,
						 Code:code,
						 ExtData:"ExtData"
			         }));
	}

	//设置座席状态
	WebCCX.prototype.SetAgentState = function(agentid,type,status,Reason)
	{	
	   this.ws.send(JSON.stringify({  //发送示忙，示闲，休息数据
			             Command:"SetAgentState",
			             OpAgentID:agentid,
						 StateType:1,
						 AgentState:status,
						 Reason:Reason,
						 ExtData:"ExtData"
			         }));  
	}

	 //应答呼叫
	WebCCX.prototype.AnswerCall= function(CallID)
	{
		this.ws.send(JSON.stringify({    //发送呼叫应答数据
			             Command:"AnswerCall",
			             CallID:CallID,
						 ExtData:"ExtData"
			         }));  
	}

	//关闭呼叫
	WebCCX.prototype.ClearCall = function(CallID)
	{
		this.ws.send(JSON.stringify({	//发送挂机数据
			             Command:"ClearCall",
			             CallID:CallID,
						 ExtData:"ExtData"
			         })); 
	}

	//保持呼叫
	WebCCX.prototype.HoldCall = function(CallID)
	{
		this.ws.send(JSON.stringify({   //发送保持呼叫数据
			             Command:"HoldCall",
			             CallID:CallID,
						 ExtData:"ExtData"
			         })); 
	}

	 //取回呼叫
	WebCCX.prototype.RetrieveCall = function(CallID)
	{
		this.ws.send(JSON.stringify({  //发送重新接入被保持呼叫的数据，参数(strCallID 被重接的呼叫编号)
			             Command:"RetrieveCall",
			             CallID:CallID,
						 ExtData:"ExtData"
			         })); 	  
	}

	  //磋商呼叫
	WebCCX.prototype.ConsultCall = function(CallID, Number, SendAni, CallData)
	{
		if (Number	==	"")
		{
			return;
		}    
		this.ws.send(JSON.stringify({	   // 建立磋商呼叫，参数(CallID 当前活动呼叫ID；DeviceID 被磋商的座席分机号；磋商呼叫的随路数据)
			             Command:"ConsultCall",
			             CallID:CallID,
						 Number:Number,
						 SendAni:"",
						 CallData:CallData,
						 ExtData:"ExtData"
			         }));
	}

	//转接呼叫
	WebCCX.prototype.TransferCall = function(HoldCallID,ActiveCallID,CallData)
	{
	   this.ws.send(JSON.stringify({       //发送转接呼叫数据
			             Command:"TransferCall",
			             HeldCallID:HoldCallID,
						 ActiveCallID:ActiveCallID,
						 CallData:CallData,
						 ExtData:"ExtData"
			         }));
	}

	//单步转接
	WebCCX.prototype.SingleStepTransferCall = function (callid,Callee,CallData)
	{
	   this.ws.send(JSON.stringify({
			             Command:"SingleStepTransferCall",
			             CallID:callid,
						 Number:Callee,
						 SendAni:"",
						 CallData:CallData,
						 ExtData:"ExtData"
			         }));
	}

	//转接IVR
	WebCCX.prototype.TransferCallToIVR= function(callid,IvrNumber,FlowType,IvrFlowID,IvrNode,CallData)
	{
	   this.ws.send(JSON.stringify({
			             Command:"TransferToIVR",
			             CallID:callid,
						 IvrNumber:IvrNumber,
						 IvrFlowType:FlowType,
						 IvrFlow:IvrFlowID,
						 IvrNode:IvrNode, 
						 CallData:CallData,
						 ExtData:"ExtData"
			         }));
	}
	  //外呼
	WebCCX.prototype.OutbondCall = function(Callee,CallData)
	{
	  this.ws.send(JSON.stringify({   //呼出，参数(strCallNumber 被叫号码,随路的信息)
		             Command:"MakeCall",
		             Number:Callee,
					 SendAni:"",
					 CallData:CallData,
					 ExtData:"ExtData"
		         }));  
	}

	//会议
	WebCCX.prototype.ConferenceCall = function(HoldCallID,ActiveCallID,CallData)
	{
	 this.ws.send(JSON.stringify({
		             Command:"ConferenceCall",
		             HeldCallID:HoldCallID,
					 ActiveCallID:ActiveCallID,
					 CallData:CallData,
					 ExtData:"ExtData"
		         }));
	}

	//监听呼叫
	WebCCX.prototype.StartMonitorCall = function(CallID,DeviceID) 
	{
		this.ws.send(JSON.stringify({
			             Command:"MonitorCall",
						 MonitoredDevice:DeviceID,
			             CallID:CallID,
						 ExtData:"ExtData"
			         }));
	}

	WebCCX.prototype.StopMonitorCall = function(CallID) 
	{
		this.ws.send(JSON.stringify({
			             Command:"StopMonitorCall",
			             CallID:CallID,
						 ExtData:"ExtData"
			         }));
	}

	//截获呼叫
	WebCCX.prototype.InterceptCall	=	function(CallID,DeviceID) 
	{
		this.ws.send(JSON.stringify({
			             Command:"InterceptCall",
						 InterceptedDevice:DeviceID,
			             CallID:CallID,	  			 
						 ExtData:"ExtData"
			         }));
	}

	//加入呼叫
	WebCCX.prototype.JoinCall	=	function(CallID,DeviceID) 
	{
		this.ws.send(JSON.stringify({
			             Command:"JoinCall",
						 JoinedDevice:DeviceID,
			             CallID:CallID,  			 
						 ExtData:"ExtData"
			         }));
	}

	//放音收码
	WebCCX.prototype.ReceiveDTMF = function(CallID,ivrEntry,callData)
	{
		this.ws.send(JSON.stringify({
			             Command:"RecvDTMF",
			             CallID:CallID,
						 DTMFEntry:ivrEntry,
						 CallData:callData,
						 ExtData:"ExtData"
			         }));
	}
	//话后超时事件报告
	WebCCX.prototype.SetAFWKTimeout=function(nAFWKTimeout, nAFWKPreSeconds){  
		this.ws.send(JSON.stringify({
				             Command:"SetAFWKTimeout",
				             AFWKTimeout:nAFWKTimeout,//5
				             AFWKPreSeconds:nAFWKPreSeconds,//8
				             ExtData:"ExtData"
				         }));
	   }
	   
	   //获取在线客户信息表
	WebCCX.prototype.GetAgentList=function(QueueID) 
	{
		//var rc = CtiClient.CompleteMessage(CallID, reason, code);
		this.ws.send(JSON.stringify({
			             Command:"GetAgentList",
			             QueueID:QueueID
			         }));
	}

	//设置心跳
	var heartBeatFlag;//心跳标志
	WebCCX.heartBeat = function()
	{
		if((Agent_m_eState[Agent_E_AGENT_STATE_TYPE_BASE] == Agent_E_AGENT_STATE_LOGOUT)
			&&(Agent_m_eState[Agent_E_AGENT_STATE_TYPE_VOICE] == Agent_E_AGENT_STATE_INIT) 
			&&(Agent_m_eState[Agent_E_AGENT_STATE_TYPE_MEDIA] == Agent_E_AGENT_STATE_INIT))
			return;
		var time = CurentTime();
		wss.send(JSON.stringify({
			"Time":time
			}));
		hearBeatFlag = window.setTimeout(WebCCX.heartBeat,25000);
	}

	//获取分机号
	WebCCX.prototype.getDeviceID = function()
	{
		 return localStorage.getItem("extno");
	}

	//设置分机号
	WebCCX.prototype.setDeviceID = function(deviceID)
	{
		 return localStorage.setItem("extno", deviceID);
	}

	//获取分机号(静态函数，方便分机配置窗口调用)
	WebCCX.getDeviceID = function()
	{
		 return localStorage.getItem("extno");
	}


	//设置分机号(静态函数，方便分机配置窗口调用)
	WebCCX.setDeviceID = function(deviceID)
	{
		 return localStorage.setItem("extno", deviceID);
	}

	//获取自动示闲
	WebCCX.getAutoIdle = function()
	{
		 return localStorage.getItem("autoIdle");
	}

	//设置自动示闲
	WebCCX.setAutoIdle = function(AutoIdleFlag)
	{
		 return localStorage.setItem("autoIdle", AutoIdleFlag);
	}

	//获取自动应答
	WebCCX.getAutoAnswer = function()
	{
		 return localStorage.getItem("autoAnswer");
	}

	//设置自动应答
	WebCCX.setAutoAnswer = function(AutoAnswerFlag)
	{
		 return localStorage.setItem("autoAnswer", AutoAnswerFlag);
	}

	//点击事件返回结果处理
	function onMessage(event) 
	{
	   var res = parseJson(event.data);
	   //console.log("event.data:"+event.data);
	   WebCCX.getEventOrResp('OnMessage')(event.data);
	   if(res.Resp!=null)
		   OnResp(res);
	   else if(res.Event!=null)
		   OnEvent(res);
	   else 
		   alert('错误'+res);
	 }

	function onError(event) 
	{
	   alert("无法连接服务器，请升级浏览器"+","+event.data);
	 }
	 
	function onClose(event) 
	{
		Agent_m_eState[Agent_E_AGENT_STATE_TYPE_BASE]		=	Agent_E_AGENT_STATE_INIT; 
		Agent_m_eState[Agent_E_AGENT_STATE_TYPE_VOICE]	=	Agent_E_AGENT_STATE_INIT;
		Agent_m_eState[Agent_E_AGENT_STATE_TYPE_MEDIA]	=	Agent_E_AGENT_STATE_INIT;
		alert("WebSocketCcxServer服务器连接关闭"+":"+event.reason);
	}

	//Resp事件处理
	function OnResp(res)
	{
	   switch(res.Resp)
	   {
			case  "Login":
				if(res.Result==99999999) //99999999,临时返回
				{
				 return true;
				}
				if(res.Result==0)
				{
				 OnLoginResp(res.Result, res.Desc);//0-成功,其他失败 
				}else
				{
					alert("签入失败"+res);
				}
				break;
			case  "Logout":
			    WebCCX.getEventOrResp('OnLogoutResp')(res.Result, res.Desc);
				break;
			case  "SetAgentState":
				OnAgentStateChangedEx(res.Result, res.Desc);//设置座席状态
				break;
			case  "GetAgentList":
   			    WebCCX.getEventOrResp('OnAgentList')(res.Result, res.Desc,res.AgentListData);
   			    break;
	   }
	}

	//Event事件处理
	function OnEvent(res)
	{
	   switch(res.Event)
		{
			case  "OnCallStateChanged":
				WebCCX.getEventOrResp('OnCallStateChanged')(res.CallID, res.State,res.StateName);
				break;
			case  "OnAgentStateChangedEx":
				OnAgentStateChangedEx(res.StateType,res.StateCode, res.StateName, res.SubCode, res.SubName);
				break;
			case  "OnCallComing":
				WebCCX.getEventOrResp('OnCallComing')(res.CallID, res.CallType, res.CallDirect, res.OrgANI, res.OrgDNIS, res.AlertDev, res.CallData, res.ImrQueueID);
				break;
			case  "OnCallConnected":
				WebCCX.getEventOrResp('OnCallConnected')(res.CallID, res.CallType,res.CallDirect, res.OrgANI, res.OrgDNIS, res.AnsweringDev, res.CallData);
				break;
			case  "OnCallOver":
				WebCCX.getEventOrResp('OnCallOver')(res.CallID, res.Reason, res.Code, res.ReasonDesc);
				break;
			case  "OnCallTransferred":
				WebCCX.getEventOrResp('OnCallTransferred')(res.CallID,res.MsgType,res.CallType, res.CallDirect, res.OrgANI, res.OrgDNIS, res.TransferredOut, res.TransferredIn, res.DataLen, res.CallData);
				break;
			case  "OnCalloutInit":
				WebCCX.getEventOrResp('OnOBCallDialing')(res.CallID, res.CallType, res.CallDirect, res.OrgANI, res.OrgDNIS, res.DNIS, res.CallData);
				break;
			case  "OnCalloutRingback":
				WebCCX.getEventOrResp('OnOBCallAlerting')(res.CallID, res.AlertingDevice);
				break;
			case  "OnCalloutAnswered":
				WebCCX.getEventOrResp('OnOBCallAnswered')(res.CallID, res.State,res.StateName);
				break;
			case  "OnConnectDone":
				clearTimeout(heartBeatFlag);
				break;
			case  "Disconnected":
				OnDisconnected(res.Result, res.Desc);
				break;
			case 'OnAFWKTimeout':
				WebCCX.getEventOrResp('OnAFWKTimeout')(res.Flag);
				break;
		}
	}

	function OnLoginResp(nResult, lpszDesc)//CtiClient
	{
		//定时的向服务器发送心跳
		window.setTimeout(WebCCX.heartBeat,25000);
		//关闭无效的WebChat呼叫
		//openccx.CloseInvalidWebChat();
		//签入成功回调
		WebCCX.getEventOrResp('OnLoginResp')(nResult, lpszDesc);
	}


	function OnAgentStateChangedEx(nStateType,nStateCode,lpszStateName, nSubCode,lpszSubName)
	{
		var js = new jsAgentStatus();
		js.Changed(nStateType,nStateCode);
		WebCCX.getEventOrResp('OnAgentStateChangedEx')(nStateType,nStateCode,lpszStateName, nSubCode,lpszSubName);
	}

	//WebCCXGW断开，清除当前状态
	function OnDisconnected(nResult, lpszResultDesc)
	{
		Agent_m_eState[Agent_E_AGENT_STATE_TYPE_BASE]	=	Agent_E_AGENT_STATE_INIT; 
		Agent_m_eState[Agent_E_AGENT_STATE_TYPE_VOICE]	=	Agent_E_AGENT_STATE_INIT;
		Agent_m_eState[Agent_E_AGENT_STATE_TYPE_MEDIA]	=	Agent_E_AGENT_STATE_INIT;
			//停止发送心跳
			alert("OnDisconnected" + nResult);
			onClose(4999);
			wss.close();
			//WebCCXGW断开接口
			WebCCX.getEventOrResp('OnDisconnected')(nResult, lpszResultDesc);
	}

	//---------------------------jsAgentStatus 类---------------------

	function jsAgentStatus()
	{
		
	}

	//状态改变
	jsAgentStatus.prototype.Changed	=	function(type,code)
	{
		Agent_m_eState[type] = code;
		if (Agent_m_eState[Agent_E_AGENT_STATE_TYPE_BASE] == Agent_E_AGENT_STATE_LOGOUT)
		{
			Agent_m_eState[Agent_E_AGENT_STATE_TYPE_VOICE] = Agent_E_AGENT_STATE_INIT ;
			Agent_m_eState[Agent_E_AGENT_STATE_TYPE_MEDIA] = Agent_E_AGENT_STATE_INIT ;
		}
		
	}

	//取坐席状态值
	jsAgentStatus.prototype.GetDescValue	=	function(StateType)
	{
		var value	=	Agent_m_eState[StateType];
		return value;
	}

	//取状态描述
	jsAgentStatus.prototype.GetDesc	=	function()
	{
	   // var st = Agent_m_eState[0]; 
		var Desc = Agent_StatDesc[Agent_m_eState[Agent_E_AGENT_STATE_TYPE_VOICE]]
		return Desc;
	}



	//通用取当前时间
	function CurentTime(){ 
	   var now = new Date();
			
	   var year = now.getFullYear();       //年
	   var month = now.getMonth() + 1;     //月
	   var day = now.getDate();            //日
		   
	   var hh = now.getHours();            //时
	   var mm = now.getMinutes();          //分
	   var sc = now.getSeconds(); //获取当前秒数(0-59) 
	   var scc = now.getMilliseconds(); //获取当前毫秒数(0-999) 
	   var clock = year + "-";
			
	   if(month < 10)
		  clock += "0";
			
		  clock += month + "-";
			
	   if(day < 10)
		  clock += "0";
				
		  clock += day + " ";
			
	   if(hh < 10)
		  clock += "0";    
		  clock += hh + ":";
		  if (mm < 10) clock += '0'; 
			 clock += mm +":";
		  if (sc < 10) 
				clock += '0'; 
			 clock += sc +" "+scc;  
		  return(clock); 
	} 

	/**
	 * 将字符串转成json格式
	 */
	function parseJson(str){
	   try{
			return eval('('+str+')');
		}catch(e){
			return null;
		}
	}